<?php

namespace App;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;

class Goods extends Model
{
    protected $guarded=[];
    protected $casts=[
        'pictures'=>'json'
    ];
    public function skus()
    {
        return $this->hasMany(Sku::class,'goods_id','id');
    }
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
    public function category()
    {
        return $this->belongsTo(Category::class,'category_id','id');
    }
    public function comments()
    {
        return $this->hasMany(Comment::class,'goods_id','id')->where('parent_id','=',0);
    }
}
